// hooks:钩子   钩子函数习惯以use开头

import { useIntersectionObserver } from "@vueuse/core"
import { ref } from "vue"

// 封装数据懒加载的函数
export function useLazyData(callback:()=>void){
    const target = ref(null)
    const {stop} = useIntersectionObserver(target,([{isIntersecting}],observerElement)=>{
      if(isIntersecting){
        console.log(observerElement);
        
        callback()
        stop()
      }
    },{
      threshold:0
    })

    return target
}